const EventEmitter = require('events').EventEmitter
const RunTime = require("./Config")

class Response extends EventEmitter{

    invoke( resp ) {
        if( typeof( resp ) === 'object' ){
            const invokeName = resp.header.api 
            const body = resp.body 
            this.emit( invokeName , body )
        }
    }
}

const Resp = new Response() 

//login .
Resp.on("login" , body => {
    if( body.moduleTag ) {
        RunTime.moduleTag = body.moduleTag
    }
})

Resp.on('onReqAccountDetail' , body => {
    // console.log( body )
    RunTime.account = body 
})


module.exports = Resp 